package com.foo.dao.testcases;

import static org.junit.Assert.*;

import com.foo.exceptionhandling.ServiceUnavailableException;

import org.junit.Test;

import org.example.www.movie.Movie;
import org.example.www.movie.Movies;

import com.foo.dao.MovieDAO;

public class MovieDAOTestCases 
{
	@Test
	public void testGetAllMovieData() 
	{
		try 
		{
			Movies allData =  MovieDAO.getAllMovieData();
			assertNotNull(allData);
		} 
		catch (ServiceUnavailableException e) 
		{
			fail("Get All Movie Data testcase failed");
		}
	}
	
	@Test
	public void testGetMovieByName() 
	{
		try 
		{
			Movie specificMovie =  MovieDAO.getMovieInfoByName("Love");
			assertEquals("Love", specificMovie.getMovieName());
		} 
		catch (ServiceUnavailableException e) 
		{
			fail("Get Movie Data By Name testcase failed");
		}
	}
	@Test
	public void testGetMovieByGenre() 
	{
		try 
		{
			Movie[] moviegenre =  MovieDAO.getMovieInfoByGenre("Action");
			assertEquals(9, moviegenre.length);
		} 
		catch (ServiceUnavailableException e) 
		{
			fail("Get Movie Data By Genre testcase failed");
		}
	}
	@Test
	public void testGetMovieByTime() 
	{
		try 
		{
			Movies movietime =  MovieDAO.getMovieInfoByTime("4:00pm");
			assertNotNull(movietime);
		} 
		catch (ServiceUnavailableException e) 
		{
			fail("Get Movie Data By Time testcase failed");
		}
	}
	
	@Test
	public void testGetMovieByTheatre() 
	{
		try 
		{
			Movie[] movietheatre =  MovieDAO.getMovieInfoByTheatre("Winchester 23");
			assertEquals(5, movietheatre.length);
		} 
		catch (ServiceUnavailableException e) 
		{
			fail("Get Movie Data By Time testcase failed");
		}
	}
	@Test
	public void testGetMovieByType() 
	{
		try 
		{
			Movie[] movietype =  MovieDAO.getMovieInfoByType("PG");
			assertEquals(31, movietype.length);
		} 
		catch (ServiceUnavailableException e) 
		{
			fail("Get Movie Data By Time testcase failed");
		}
	}
}
